package com.leetcode.Offer;

import java.util.Arrays;

public class JZ45_2 {
    public String minNumber(int[] nums) {

        if (nums.length == 0) {
            return "";
        }
        String[] strings = new String[nums.length];
        int index = 0;
        for (int num : nums) {
            strings[index++] = String.valueOf(num);
        }
        Arrays.sort(strings, (x, y) -> (x + y).compareTo(y + x));

        StringBuilder sb = new StringBuilder();
        for (String string : strings) {
            sb.append(string);
        }
        return sb.toString();
    }

}
